package lc.q101_150;

import lc.TreeNode;

public class Q129 {

    public int sumNumbers(TreeNode root) {
        return summers(root, 0);
    }

    private int summers(TreeNode root, int currentVal) {
        if (root == null) {
            return 0;
        }
        int sum = currentVal * 10 + root.val;
        if (root.left == null && root.right == null) {
            return sum;
        } else {
            return summers(root.left, sum) + summers(root.right, sum);
        }
    }

}
